﻿using System.Collections.Generic;

namespace Pixster.Models
{
    public class PixsterViewModel
    {
        public IList<PixDirectory> Sitemap { get; set; }
        public PixDirectory CurrentDirectory { get; set; }
        public PixAlbum CurrentAlbum { get; set; }
        public PixPhoto CurrentPhoto { get; set; }

        public PixPhoto NextPhoto
        {
            get
            {
                if(CurrentAlbum == null || CurrentAlbum.Photos == null) return null;

                if (CurrentPhoto == null) return CurrentAlbum.Photos[0];

                var index = CurrentAlbum.Photos.IndexOf(CurrentPhoto);

                return index >= CurrentAlbum.Photos.Count - 1 ? null : CurrentAlbum.Photos[index + 1];
            }
        }

        public PixPhoto PreviousPhoto
        {
            get
            {
                if (CurrentAlbum == null || CurrentAlbum.Photos == null) return null;

                if (CurrentPhoto == null) return CurrentAlbum.Photos[0];

                var index = CurrentAlbum.Photos.IndexOf(CurrentPhoto);

                return index <= 0 ? null : CurrentAlbum.Photos[index - 1];
            }
        }
    }
}